#include "constant.h"

Constant::Constant(int integer) : AbstractNode()
{
	c_type="integer";
	c_integer=integer;	
}

Constant::Constant(std::string * str) : AbstractNode()
{
	c_type="string";
	c_str=str;
}

void Constant::write(GraphStream * s)
{
	this->accept(s);
	char str[100];

	if (c_type=="string") {
		strcpy(str,c_str->c_str());	
	}
	else if (c_type=="integer") {
		itoa(c_integer,str,10);
	}

	fprintf(s->stream,"\tnode_%d [label=\"Constant\\n%s\\n%s\" shape=\"rectangle\"]\n", this->number(),c_type.c_str(),str);
}

Constant::~Constant(void)
{
	delete c_str;
}
